package cn.net.shuxing.yifu.common.service;

import cn.net.shuxing.yifu.common.bean.Country;
import cn.net.shuxing.yifu.common.mapper.CountryMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
public class CountryService extends BaseService<Country, CountryMapper> {
    public List<Country> searchByName(String name,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        if (name==null){
            return getAll();
        }
        Example example = new Example(Country.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("countryName", "%" + name + "%");
        criteria.orLike("countryNameEnglish", "%" + name + "%");
        criteria.andEqualTo("deleted", '0');
        example.and(criteria);
        return getsByExample(example);
    }
}
